<template>
<div class="base-box foot-margin">
    <ul class="resource-ul-box min-h">
        <li class="resource-book-li f1" v-for="book in getBooks" @click="goto(book.id)" :key="book.id">
            <section class="cz-c resource-book-1">
                <img class="search-book-img" :src="getUrl(book.image)">
            </section>
            <section class="resource-book-2">
                <p class="ellipsis">{{book.title}}</p>
                <p class="ellipsis font1">主编:{{book.editor}}</p>
            </section>
        </li>
    </ul>
</div>
</template>
<script setup>
import {computed} from 'vue'
import books from '../assets/json/books.json'
import {useRouter} from 'vue-router'
const router = useRouter()
const props = defineProps(['title'])
const getBooks = computed(()=>{return books.filter(item=>item.title.includes(props.title))})
const getUrl = (url)=>{
    return new URL(url,import.meta.url).href
}
const goto = (id)=>{router.push('/book/'+id)}
</script>
<style scoped>
.base-box {
    width: 1200px;
    height: auto;
    overflow: hidden;
    margin: 0 auto;
    background-color: #fff;
}

.foot-margin {
    padding-bottom: 60px;
}

.resource-ul-box {
    width: 1300px;
    height: auto;
    overflow: hidden;
    margin: 0px;
    padding: 0px;
}

.min-h {
    min-height: 600px
}

.resource-book-li {
    width: 224px;
    height: 340px;
    margin: 20px 20px 0px 0px;
    overflow: hidden;
}

.f1 {
    float: left;
}

.resource-book-1 {
    width: 222px;
    height: 270px;
    border: 1px solid #EEEEEE;
    overflow: hidden;
}

.cz-c {
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-book-img {
    max-height: 270px;
    overflow: hidden;
    width: auto;
}

img {
    border: none;
    vertical-align: middle;
    overflow: hidden;
    image-rendering: -moz-crisp-edges;
    image-rendering: -o-crisp-edges;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.resource-book-2 {
    line-height: 28px;
    font-size: 14px;
    width: 204px;
    text-align: left;
    padding: 10px;
    color: #333333;
}

.ellipsis {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.font1 {
    color: #999999;
}
</style>